﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GC_School_of_Careers
{
    public partial class uclogin : UserControl
    {
        public uclogin()
        {
            InitializeComponent();
            this.tALUSERTableAdapter.Fill(this.dsuser.TALUSER);
        }

        private void blogin_Click(object sender, EventArgs e)
        {
            GlobalUser.GlobalVar = "";
            for (int i = 0; i < (this.dgvusers.Rows.Count - 1); ++i)
            {
                if ((Convert.ToString(dgvusers.Rows[i].Cells[0].Value) == txtusername.Text) & (Convert.ToString(dgvusers.Rows[i].Cells[1].Value) == txtpassword.Text))
                {
                    MessageBox.Show("Login Succesfull");
                    this.Dispose(false);
                    GlobalUser.GlobalVar = txtusername.Text;
                }
                else
                {
                    MessageBox.Show("User or Password incorrect");
                    GlobalUser.GlobalVar = "";
                }
            }

        }
    }
}
